﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using CommonTypes;
using Collertor;
namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            TargetItem target = new TargetItem();
            target.encoding = Encoding.GetEncoding("GB2312");
            target.url = "http://www.jumpcn.com";
            WorkThread job = new WorkThread();
            job.TargetItem = target;
            job.OnFinished += OnJobFinished;
            job.OnLogging += OnLog;
            Console.WriteLine("使用非线程方式异步获取网页内容....\r\n");
            Console.WriteLine("执行job.getBody()....\r\n");
            job.GetBody();
            Console.ReadKey();
        }

        public static void OnJobFinished(JobFinishedEventArgs e) {
            Console.WriteLine("OnJobFinished..body is..\r\n");
            Console.Write(e.TargetNode.body);
        }

        public static void OnLog(LogEventArgs e)
        {
            Console.WriteLine("OnLog..\r\n");
            Console.Write(e.Log);
        }
    }
}
